var t;

t = require("../../05BFE3A3C6098CCF63D98BA434E9C3F4.js")(require("../../1361F626C6098CCF75079E21B079C3F4.js")), 
getApp(), Page({
    data: {
        loading: !1,
        posterSrc: null,
        imageurl: null,
        qrcode: "/static/image/ewm.jpg",
        fonts: [ "normal bold 100px NSimSun", "normal bold 80px NSimSun", "normal bold 100px NSimSun", "normal bold 80px NSimSun", "normal bold 80px NSimSun", "normal bold 80px NSimSun" ],
        titles1: [ "庆圣诞、迎新年", "新年快乐、佳节如意", "迎元旦、庆新春", "团结奋进、振兴中华", "愿你的代码永不出BUG！", "名花虽有主、挖掘最无情" ],
        titles2: [ "来给图像加节日标签吧", "来给图像加节日标签吧", "来给图像加节日标签吧", "来给图像加节日标签吧", "来给图像加节日标签吧", "来给图像加节日标签吧" ],
        title: "",
        type: 0,
        backImageUrls: [ "/static/image/share/poster/1.jpg", "/static/image/share/poster/2.jpg", "/static/image/share/poster/3.jpg", "/static/image/share/poster/4.jpg", "/static/image/share/poster/5.jpg", "/static/image/share/poster/6.jpg" ],
        backIndex: 0
    },
    onLoad: function(t) {
        this.setData({
            imageurl: "/static/image/logo.png",
            type: t.type
        }), wx.setNavigationBarTitle({
            title: "制作海报"
        });
    },
    onReady: function() {
        this._makePosterImage();
    },
    _makePosterImage: function() {
        var a = this;
        if (!this.data.loading) {
            var e = this.data, i = e.imageurl, n = void 0 === i ? null : i, o = e.titles1, s = e.type, r = e.qrcode, l = e.backImageUrls, c = e.backIndex, d = e.fonts;
            null != n ? (wx.showLoading({
                title: "生成海报..."
            }), this.data.loading = !0, new t.default(this, "festivalCanvas", 1e3, 1500).addImage({
                path: l[c],
                x: 0,
                y: 0,
                w: 1e3,
                h: 1506
            }).addText({
                text: o[s],
                x: 0,
                y: 150,
                font: d[s],
                align: "center",
                fontSize: 100,
                color: function() {
                    switch (c) {
                      case 1:
                      case 5:
                        return "#99335A";

                      case 4:
                        return "#000";

                      default:
                        return "#fff";
                    }
                }()
            }).addImage({
                path: n,
                x: 225,
                y: 395,
                w: 550,
                h: 550
            }).addImage({
                path: r,
                x: 120,
                y: 1200,
                w: 250,
                h: 250,
                radius: 125
            }).addText({
                text: "长按识别小程序码",
                x: 470,
                y: 1275,
                align: "left",
                fontSize: 40,
                color: function() {
                    switch (c) {
                      case 4:
                        return "#000";

                      case 5:
                        return "#99335A";

                      default:
                        return "#fff";
                    }
                }()
            }).addText({
                text: "免费为图像添加节日标签",
                x: 470,
                y: 1355,
                align: "left",
                fontSize: 40,
                color: function() {
                    switch (c) {
                      case 2:
                      case 3:
                        return "#fff";

                      case 5:
                        return "#99335A";

                      default:
                        return "#000";
                    }
                }()
            }).startCompound(function(t) {
                wx.hideLoading(), a.data.loading = !1, n ? a.setData({
                    posterSrc: t
                }) : a._makePosterImage();
            })) : wx.showToast({
                title: "海报生成异常，请联系作者",
                icon: "none"
            });
        }
    },
    clickChangeBackImage: function(t) {
        if (!this.data.loading) {
            var a = this.data, e = a.backIndex, i = a.backImageUrls;
            this.data.backIndex = (e + 1) % i.length, this._makePosterImage();
        }
    },
    clickSavePhoto: function(t) {
        var a = this;
        if (!this.data.loading) {
            var e = this.data.posterSrc, i = void 0 === e ? null : e;
            i ? (wx.showLoading({
                title: "正在保存..."
            }), this.data.loading = !0, wx.saveImageToPhotosAlbum({
                filePath: i,
                success: function(t) {
                    a.data.loading = !1, wx.hideLoading(), wx.showToast({
                        title: "保存到相册成功"
                    });
                },
                fail: function(t) {
                    a.data.loading = !1, wx.hideLoading(), wx.showToast({
                        title: "保存失败",
                        icon: "none"
                    });
                }
            })) : wx.showToast({
                title: "海报生成异常，请联系作者",
                icon: "none"
            });
        }
    },
    onShareAppMessage: function() {
        return {
            title: "@微信官方，给我2021国庆的国旗渐变头像",
            desc: "领取你的国庆头像，为祖国加油",
            imageUrl: "/static/image/share_img.png",
            path: "/pages/index/index",
            success: function(t) {
                console.log(t);
            }
        };
    },
    onShareTimeline: function() {
        return {
            title: "@微信官方，给我2021国庆的国旗渐变头像",
            desc: "领取你的国庆头像，为祖国加油",
            imageUrl: "/static/image/share_img.png",
            path: "/pages/index/index",
            success: function(t) {
                console.log(t);
            }
        };
    }
});